
class AudioMgr {
    constructor(){
        this.bmID = {};
    };
    playMusic(bm,loop){
        let url = `sounds/bm/${bm}`;
        cc.loader.loadRes(url, cc.AudioClip, (err, audioClip)=> {
            if(err){
                console.log( "==>"+ typeof audioClip);
                return;
            }
            let audioID = cc.audioEngine.playMusic(audioClip, loop);
            this.bmID[audioID] = audioID;
            console.log('this.bmID',this.bmID);
        });
    };
    playEffect(ef,loop){
        let url = `sounds/effect/${ef}`;
        cc.loader.loadRes(url, cc.AudioClip, (err, audioClip)=> {
            if(err){
                console.log( "==>"+ typeof audioClip);
                return;
            }
            let audioID = cc.audioEngine.playEffect(audioClip, loop);
            if(loop){
                this.bmID[audioID] = audioID;
                console.log('this.bmID',this.bmID);
            }
        });
    };
    static getInstance(){
        if(!this.intance){
            this.intance = new AudioMgr();
        }
        return this.intance;
    };
}
module.exports = AudioMgr;

